//
//  AppDelegate.swift
//  HeadlineNews
//
//  Created by han on 2019/5/30.
//  Copyright © 2019 han. All rights reserved.
//

import UIKit

@UIApplicationMain

// 因为LaunchScreen.storyboard 在显示Assets中图片时，有可能会显示不出来，例如iPhone8P 11.2版本时，所以把launchImage放在根目录下。
// 在加载的图片时，直接用launchImage 不要加后缀，这样系统就会根据机型加载@2x 和 @3x 图片 UIImage(named: "launchImage") 和加载Assets中图片一样。

// UIImage.init(contentsOfFile: Bundle.main.path(forResource: "launchImage", ofType: "png")!) 也会自动加载@2x @3x

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
   
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        window = UIWindow.init(frame: UIScreen.main.bounds)
        window?.backgroundColor = UIColor.black
        CommondBuilder(keyWindow: window!).builders().forEach { $0.execute() }
    
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
       
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
        // 护眼模式
        //由于护眼模式需要修改keyWindow所以加载本地护眼模式时，需要设置在Active的时候
        HeadlineEyeCareLevel.initLocalEyeCareLevel()
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

